package com.itheima.controller;

import com.itheima.common.Code;
import com.itheima.common.MessageConstant;
import com.itheima.common.Result;
import com.itheima.entity.SetmealDish;
import com.itheima.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author suiweihua
 * @version 1.0
 * @description: TODO 购物车套餐分类展示菜品详情
 * @date 2022/6/8 19:42
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealDishController {
    @Autowired
    private SetmealDishService setmealDishService;
    /**
     * 功能描述 :点击套餐回显菜品数据
     * @return : com.itheima.common.Result
     */
    @GetMapping("/dish/{id}")
    public Result dishList(@PathVariable("id")Long id){
        List<SetmealDish> setmealDishList = setmealDishService.dishList(id);
        if (setmealDishList == null){
            return new Result(Code.ERROR, MessageConstant.SETMEAL_SHOW_GET_ERROR);
        }
        return new Result(Code.OK,MessageConstant.SETMEAL_SHOW_GET_SUCCESS,setmealDishList);
    }
}
